﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAL.Entities;

namespace DAL.EntitesDAL
{
    public class TKBDAL : BaseDAL, UTL.IBaseDAL
    {
        #region Implement

        public int Count()
        {
            throw new NotImplementedException();
        }

        public DataTable Select()
        {
            return ExecuteQuery("sp_SelectAll_TKB");
        }

        public DataTable Select(object obj)
        {
            throw new NotImplementedException();
        }

        public object GetByKey(object key)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string id)
        {
            throw new NotImplementedException();
        }

        public bool Delete(string id1, string id2, string id3)
        {
            var sql = "sp_Delete_TKB '{0}' '{1}' '{2}' ";
            sql = string.Format(sql, id1, id2, id3);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Insert(object obj)
        {
            var o = (TKB)obj;
            var sql = "set dateformat dmy; execute sp_Insert_TKB '{0}', '{1}', '{2}', '{3}', '{4}', N'{5}' ";
            sql = string.Format(sql, o.Ngayhoc.ToString("dd/MM/yyyy"), o.MacaID, o.MaphongID, o.MalopID, o.MaGVID, o.Dayphan);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Update(object obj)
        {
            var o = (TKB)obj;
            var sql = "set dateformat dmy; execute sp_Update_TKB '{0}', '{1}', '{2}', '{3}', '{4}', N'{5}' ";
            sql = string.Format(sql, o.Ngayhoc.ToString("dd/MM/yyyy"), o.MacaID, o.MaphongID, o.MalopID, o.MaGVID, o.Dayphan);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public DataTable Search(string name)
        {
            throw new NotImplementedException();
        }

        
        #endregion
    }
}
